import { makeAutoObservable } from 'mobx';

import { hasAccessToken, logoutToCleansSession } from '@/utils/config';

export default class GlobalStore {
  /** 国际化标识 */
  internationalizationFlag = false;

  /** 是否已授权 */
  authorized = hasAccessToken();

  constructor() {
    makeAutoObservable(this);
  }

  /** 登陆成功 */
  loginAuthorize() {
    this.authorized = true;
  }

  /** 登出成功 */
  logoutUnAuthorize() {
    // 清除系统信息
    logoutToCleansSession();
    this.authorized = false;
  }
}

export const globalStore = new GlobalStore();
